﻿using System;

using ServiceStack.Text;

namespace Fuse8.ContentManagementFramework.SystemFacade.Utilities
{
    public static class ServiceStackTypeSerializer<T> where T : class, new()
    {
        private static TypeSerializer<T> _instance = new TypeSerializer<T>();

        public static string Serialize(T obj)
        {
            return obj != null ?
                _instance.SerializeToString(obj) :
                null;
        }

        public static T Deserialize(string storedObj)
        {
            return !string.IsNullOrWhiteSpace(storedObj) ?
                _instance.DeserializeFromString(storedObj) :
                default(T);
        }
    }
}
